import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {

  id?: number,
  nickname?: string,
  loginName?: string,
  phone?: string,
  lastLoginTime?: string,
  lastLoginIp?: string,
  unityId?: number,
  unityName?: string,
  remark?: string,
  confirmPassword?: string,
  password?: string,
  status?: string,
}
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = '/system/system/v2/customer/users';
const Url = '/system/system/v2/customer/user';
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
/** 1.2.10.6 查询人员(所属个体下拉框) */
export const getIndivduaiSelectList = (params?: object) => {
  return http.request<commonResult<any>>("get", '/system/system/v2/customer/user-list', {
    params
  });
}

/** 1.2.10.8 下载导入模板 */
export const download = (params?: object) => {
  return http.request<Blob>("get", '/system/system/v2/customer/download', {
    params,
     responseType: 'blob'
  });
};

/** 1.2.10.7 导入个体 */
export const importIndividual = (data?: object) => {
  return http.request<commonResult<any>>("post", '/system/system/v2/customer/import', {
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}